Add AI skill that checks for any unused exports#1818
Conversation
|
[APPROVALNOTIFIER] This PR is APPROVED Approval requirements bypassed by manually added approval. This pull-request has been approved by: The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
1 similar comment
|
[APPROVALNOTIFIER] This PR is APPROVED Approval requirements bypassed by manually added approval. This pull-request has been approved by: The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (5)
✅ Files skipped from review due to trivial changes (2)
🚧 Files skipped from review as they are similar to previous changes (3)
📝 WalkthroughWalkthroughThis PR internalizes four previously exported items across three source files ( ChangesRemoval of Unused Exports
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
/cherry-pick release-4.19 |
|
@kyoto: once the present PR merges, I will cherry-pick it on top of DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
.cursor/skills/unused-exports/SKILL.md (1)
23-31: Broaden module-path resolution to avoid false positives.The current wording implies
exposedModulesalways maps tosrc/<path>.ts; this can miss*.tsxorindex.ts(x)entry points.Proposed doc tweak
-Read `package.json` field `consolePlugin.exposedModules`. Each value is a module -path relative to `src/` (e.g. `"./flags"` → `src/flags.ts`). These modules are +Read `package.json` field `consolePlugin.exposedModules`. Each value is a module +path relative to `src/` (e.g. `"./flags"` may resolve to `src/flags.ts`, +`src/flags.tsx`, `src/flags/index.ts`, or `src/flags/index.tsx`). These modules are loaded at runtime by the OpenShift console framework — their exports are used externally even though nothing inside this repo imports them.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.cursor/skills/unused-exports/SKILL.md around lines 23 - 31, The docs assume consolePlugin.exposedModules always maps to src/<path>.ts which causes false negatives for .tsx or index files; update the module-path resolution guidance to, when mapping each exposedModules entry to a file, try resolving the exact path as given and fall back to src/<path>.ts, src/<path>.tsx, src/<path>/index.ts, and src/<path>/index.tsx (and accept explicit extensions), and when parsing console-extensions.json $codeRef values map the ModuleName back using that broadened resolution so export references (ModuleName or ModuleName.exportName) correctly identify entry points.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In @.cursor/skills/unused-exports/SKILL.md:
- Around line 23-31: The docs assume consolePlugin.exposedModules always maps to
src/<path>.ts which causes false negatives for .tsx or index files; update the
module-path resolution guidance to, when mapping each exposedModules entry to a
file, try resolving the exact path as given and fall back to src/<path>.ts,
src/<path>.tsx, src/<path>/index.ts, and src/<path>/index.tsx (and accept
explicit extensions), and when parsing console-extensions.json $codeRef values
map the ModuleName back using that broadened resolution so export references
(ModuleName or ModuleName.exportName) correctly identify entry points.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 15cf0746-3497-466b-95e3-ceb5f7f323ea
📒 Files selected for processing (6)
.cursor/skills/unused-exports/SKILL.mdsrc/error.tssrc/flags.tssrc/hooks/useOpenOLS.tssrc/redux-reducers.tssrc/types.ts
|
Do you expect to run this often? It feels like you run it once and then only when the exports drift. You could get 90% of this in CLAUDE.md with "To check for unused exports, run npx ts-unused-exports tsconfig.json --findCompletelyUnusedFiles --showLineNumber --searchNamespaces. Exports referenced via $codeRef in console-extensions.json are consumed externally by the OpenShift console framework, filter those from the results." Alternatively you could use "knip". It finds unused exports, files, dependencies, and types in one pass. Crucially, it has native entry point configuration you define your entry points in knip.json and it filters automatically, eliminating the need for the manual Steps 2-3 entirely. You could add knip to the lint pipeline and remove the skill entirely. |
7f0f2a0 to
40d95eb
Compare
|
Thanks @joshuawilson I think there's some value in having this as a separate skill since it is something that will only be used occassionally. (Not something that the AI should consider for every task since that's probably using tokens for minimal value.) I reworked the skill to be much more succinct and also pinned the version of ts-unused-exports to avoid potential supply chain attacks. |
|
Override test failure unrelated to this change: |
|
@kyoto: Overrode contexts on behalf of kyoto: Red Hat Konflux / e2e-console-pf6 / lightspeed-console DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Also removes the unnecessary exports that it found
40d95eb to
c22c970
Compare
Also removes the unnecessary exports that it found
Summary by CodeRabbit
Documentation
Chores